package com.cysyz.module.log.business.impl;

import com.cysyz.module.log.business.AreaService;
import com.cysyz.module.log.business.domain.Province;
import com.cysyz.module.log.business.vo.AreaDto;
import com.cysyz.module.support.service.BaseService;
import com.cysyz.mylib.dao.Conds;

import java.util.ArrayList;
import java.util.List;

public class AreaServiceImpl extends BaseService implements AreaService {
	
	@Override
	public List<AreaDto> findAllPrivice()
	{
		Conds conds = new Conds();
		conds.addFilter("province", "pk", ">", "0");
		return this.list(AreaDto.class, conds);
	}
	
	@Override
	public List<AreaDto> findCityByProvince(int provinceid)
	{
		Conds conds = new Conds();
		conds.addFilter("city", "province.pk", ">", provinceid);
		conds.addFilter("city", "pk", ">", "0");
		return this.list(AreaDto.class, conds);
	}
	
	@Override
	public List<AreaDto> findTownByCity(int cityid)
	{
		Conds conds = new Conds();
		conds.addFilter("town", "city.pk", ">", cityid);
		conds.addFilter("town", "pk", ">", "0");
		return this.list(AreaDto.class, conds);
	}
	
	@Override
	public List<AreaDto> findStreetByTown(int townid)
	{
		Conds conds = new Conds();
		conds.addFilter("street", "town.pk", ">", townid);
		conds.addFilter("street", "pk", ">", "0");
		return this.list(AreaDto.class, conds);
	}
	
	@Override
	public List<AreaDto> findAllCity()
	{
		return this.list(AreaDto.class);
	}
	
	@Override
	public Province findByProvincepk(Integer provincepk)
	{
		return this.get(Province.class, provincepk);
	}
	
	@Override
	public List<Province> findGPSProvince()
	{
		Conds conds = new Conds();
		List<String> names = new ArrayList<String>();
		names.add("北京");
		names.add("河北");
		names.add("河南");
		names.add("吉林");
		names.add("山东");
		names.add("山西");
		names.add("天津");
		conds.addFilter("province", "name", "in", names );
		return this.list(Province.class, conds);
				
	}
}
